﻿using System.Collections.Generic;
using System.Xml.Linq;
using TickSharp.Core.Interfaces;
using TickSharp.Core.Model;

namespace TickSharp.Core.Infrastructure
{
    public class ClientRepository : RepositoryBase
    {
        private readonly ISerializer _serializer;

        public ClientRepository(IApiConnectionInfo apiConnectionInfo, ISerializer serializer) : base(apiConnectionInfo)
        {
            _serializer = serializer;
        }

        public ClientRepository(IApiConnectionInfo apiConnectionInfo) : this(apiConnectionInfo, new ClientSerializer())
        {
        }

        /// <summary>
        /// Optional parameters:
        /// open (true|false)
        /// </summary>
        /// <returns></returns>
        public IEnumerable<Client> List()
        {
            string uri = BuildUrl("clients", null);

            XElement elements = GetResponse(uri);

            IEnumerable<Client> clients = _serializer.Deserialize(elements);
            return clients;
        }



    }
}